package com.ckm.controller;

import com.ckm.datasource.DynamicMongoFactory;
import com.ckm.service.TService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/mongo")
public class TestController {

    @Autowired
    private TService testService;

    @Autowired
    private DynamicMongoFactory dynamicMongoFactory;

    @GetMapping("/test")
    public void test(){
        testService.test1();
//        testService.test2();
    }

    @GetMapping("/test5")
    public void test5(){
        dynamicMongoFactory.addMongoSource("test5",new SimpleMongoClientDatabaseFactory("mongodb://localhost:27017/123"));
        testService.test5();
        dynamicMongoFactory.removeMongoSource("test5");
    }
}
